﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Group_Project_Book_Store
{
    /// <summary>
    /// Interaction logic for CreateNewInvoice.xaml
    /// </summary>
    public partial class CreateNewInvoice : Window
    {
        public CreateNewInvoice()
        {
            InitializeComponent();
            PopulateComboBoxes();
        }
        private void PopulateComboBoxes()
        {
            foreach (var payer in DatabaseClasses.DatabaseManagment.listOfPayers)
            {
                cbSearchForPayer.Items.Add(payer.payerName);    
            }
        }

        private void UpdatePayerAddress(object sender, SelectionChangedEventArgs e)
        {
            ComboBox cxBox = (ComboBox) sender;
            clsPayer payerAddress = (from payer in DatabaseClasses.DatabaseManagment.listOfPayers where payer.payerName == cxBox.SelectedItem.ToString() select payer).FirstOrDefault();
            lblShowPayerInformation.Content = payerAddress.payerName + "\r" + payerAddress.payerAddress + "\r" + payerAddress.payerCity + ", " + payerAddress.payerPostalCode + " " + payerAddress.payerZIP;
        }
    }
}
